package it.cst.entity;

import java.util.List;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.OneToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


@Entity
@Table(name="GROUPS")
public class Group {
	@Id
	@Column(name="ID")
	@GeneratedValue
	private Integer id;
	
	@Column(name="IDMATCH")
	private Integer idmatch;
	
	@Column(name="SCORE")
	private Integer score;
	
	@Column(name="COLOR")
	private String color;
	
	@Column(name="WINNER")
	private Integer winner;

	@OneToMany(fetch=FetchType.EAGER, mappedBy = "idgroup")
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(insertable=false,name="idgroup")
	private List<Player> players;
	
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(insertable=false,name="idmatch")
	private Match match;
	
	
	public Match getMatch() {
		return match;
	}

	public void setMatch(Match match) {
		this.match = match;
	}

	public List<Player> getPlayers() {
		return players;
	}

	public void setPlayers(List<Player> players) {
		this.players = players;
	}

	public Integer getWinner() {
		return winner;
	}

	public void setWinner(Integer winner) {
		this.winner = winner;
	}

	public Integer getIdmatch() {
		return idmatch;
	}

	public void setIdmatch(Integer idmatch) {
		this.idmatch = idmatch;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public Integer getId() {
		return id;
	}
}
